import { useState, useEffect } from 'react';

export const useUserInfo = () => {
  const [userInfo, setUserInfo] = useState(null);

  useEffect(() => {
    try {
      const userInfoStr = localStorage.getItem('USER_INFO');
      if (!userInfoStr) return;
      const _userInfo = JSON.parse(userInfoStr);
      setUserInfo(_userInfo);
    } catch (error) {
      // eslint-disable-next-line no-console
      console.log(error);
    }
  }, []);

  return userInfo;
};
